var t = require("../../../@babel/runtime/helpers/defineProperty"), e = getApp();

Page({
    data: {
        language: "",
        has_many_order_goods: [],
        comments: [],
        btn_class: [],
        disabled: [],
        level: 5,
        iscomment: !0,
        order: {}
    },
    onLoad: function(t) {
        t.order && (this.setData({
            order: JSON.parse(t.order ? t.order : "{}")
        }), this.data.order.id && (this.setData({
            has_many_order_goods: this.data.order.order.has_many_order_goods
        }), this.getData()));
    },
    onReady: function() {
        var t = wx.getStorageSync("langIndex");
        this.setData({
            language: t.en
        });
    },
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {},
    getData: function() {
        for (var e = 0; e < this.data.has_many_order_goods.length; e++) {
            var a;
            this.setData((t(a = {}, "comments[" + e + "]", ""), t(a, "btn_class[" + e + "]", "mod_btn bg_2"), 
            t(a, "disabled[" + e + "]", !1), t(a, "has_many_order_goods[" + e + "].evaluatebol", !1), 
            a));
        }
    },
    goEvaluate: function(e) {
        var a = e.currentTarget.dataset.evaluatebol, o = e.currentTarget.dataset.index;
        console.log(o), a ? this.setData(t({}, "has_many_order_goods[" + o + "].evaluatebol", !1)) : this.setData(t({}, "has_many_order_goods[" + o + "].evaluatebol", !0));
    },
    getStar: function(t) {
        this.setData({
            level: t.detail
        });
    },
    commentsinp: function(e) {
        var a = e.detail.value, o = e.currentTarget.dataset.index;
        this.setData(t({}, "comments[" + o + "]", a));
    },
    toComment: function(t) {
        var e = t.currentTarget.dataset.good, a = t.currentTarget.dataset.goodindex, o = this;
        0 == this.data.comments[a].length ? wx.showModal({
            title: "提示",
            content: "您还没有输入相关的评论内容",
            success: function(t) {
                t.confirm && o.submitData(e, a);
            }
        }) : o.submitData(e, a);
    },
    submitData: function(a, o) {
        var n = this, s = e.getNetAddresss("goods.comment.create-comment");
        s += "&order_id=" + this.data.order.id, s += "&goods_id=" + a.goods_id, s += "&content=" + this.data.comments[o], 
        s += "&level=" + this.data.level, e._getNetWork({
            url: s,
            success: function(e) {
                var a = e.data;
                1 == a.result ? (wx.showToast({
                    icon: "none",
                    title: a.msg,
                    duration: 1500
                }), n.setData(t({}, "disabled[" + o + "]", !0))) : wx.showToast({
                    icon: "none",
                    title: a.msg,
                    duration: 1500
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    }
});